<%@ taglib prefix="s" uri="/struts-tags"%>

<!--  newtable -->
<script type="text/javascript">
	$(document).ready(function()  {
 var catId = '10';
 var pCatId = '6';
 var pid = '15145';
 //Edit person
 $("td.listViewThS1 span.edit").click(function() {
	 pid = this.id;
	 showDetail(pid);
 });
//Delete person
$("td.listViewThS1 span.delete").click(function() {
	pid = this.id;
	if (confirm("Are you sure to delete this record ???")) {
	  deletePerson(pid);
	}
});

});

 function showDetail(pId) {
	 $.get("${pageContext.request.contextPath}/edit.action", // your page to get
	 { id: pId}, // some params to pass it
			 function(data) {
				 $("#detail_id").html(data).evalScripts();
			 });
 }

function deletePerson(pId) {
	$.get("${pageContext.request.contextPath}/delete.action", // your page to get
	{ id: pId}, // some params to pass it
			function(data) {
				$("#list_id").html(data).evalScripts();
			});
}
</script>

<s:if test="persons != null && persons.size > 0">
	<%System.out.println("persons");%>
<h1>Person Results</h1>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
   <tr>
      <td width= "10%"><!-- --></td>
      <td class="listViewThS1" scope="col" width="10%"><h3>ID</h3></td>
      <td scope="col" class="listViewThS1" width="20%"><h3>Name</h3></td>
      <td scope="col" class="listViewThS1" width="20%"><h3>Career</h3></td>
      <td scope="col" class="listViewThS1" width="20%"><h3>Birthday</h3></td>
		<td scope="col" class="listViewThS1" width="10%"><h3>Edit/Delete</h3></td>
      <td width= "10%"><!-- --></td>
   </tr>
    <%int i = 0;%>
	 <s:iterator value="persons">
   <tr>
      <td><!-- --></td>
      <td class="listViewThS1 <%=i%2!=0?"odd":"even"%>" height="20"><s:property value="id"/>&nbsp;</td>
		<td class="listViewThS1 <%=i%2!=0?"odd":"even"%>" height="20"><s:property value="firstname"/>&nbsp;<s:property value="lastName"/></td>
      <td class="listViewThS1 <%=i%2!=0?"odd":"even"%>" height="20"><s:property value="career"/>&nbsp;</td>
      <td class="listViewThS1 <%=i%2!=0?"odd":"even"%>" height="20"><s:property value="birthday"/>&nbsp;</td>
		<td class="listViewThS1 <%=i%2!=0?"odd":"even"%>" height="20"><span class="edit" id='<s:property value="id"/>'>Edit</span>/<span class="delete" id='<s:property value="id"/>'>Delete</span></td>
      <td><!-- --></td>
   </tr>
	   <%i++;%>
	 </s:iterator>
</table>
</s:if>
<!--  newtable -->

<%--
	<table>
		<s:iterator value="persons">
			<tr id="row_<s:property value="id"/>">
				<td>
					<s:property value="firstName" />
				</td>
				<td>
					<s:property value="lastName" />
				</td>
				<td>
					<s:url id="removeUrl" action="remove">
						<s:param name="id" value="id" />
					</s:url>
					<s:a href="%{removeUrl}" theme="ajax" targets="persons">Remove</s:a>
					<s:a id="a_%{id}" theme="ajax" notifyTopics="/edit">Edit</s:a>
				</td>
			</tr>
		</s:iterator>
	</table>
--%>

